<include file="__TPL__/head.html">
	<title>{$field.gname}</title>	
	<script type="text/javascript" src='__TPL__/js/head.js'></script>
	<script type="text/javascript" src='__TPL__/js/content.js'></script>
	<link rel="stylesheet" href="__TPL__/css/content.css" />
<!-- 中间主体区域 -->
	<div id="main">
	<!-- 面包屑导航 -->
	<div id="mian" class="pt10 pb10">
		<list from="$tips" name="t">
			<if value="$hd.list.t.first">
				<a href="{|U('category',array('cid'=>$t['cid']))}" class="da">{$t.cname}</a> <span class="p5 gray fv">></span>
			<else/>
				<a href="{|U('category',array('cid'=>$t['cid']))}" >{$t.cname}</a> <span class="p5 gray fv">></span>
			</if>
		</list>
		<span>{$field.gname}</span>
	</div>
	<!-- 面包屑导航结束 -->
	<!-- 放大镜区域	 -->
	<div id="fang">
	<!-- 左边区域 -->
		<div class="fang_l">
			<div class="tu">
				<span></span>
				<a href=""><list from="$pic" name="p" row="1"><img src="__ROOT__/{$p.big}" alt="" /></list></a>
				<div class="gai"></div>
				<div class="large">
					<list from="$pic" name="p" row="1"><img src="__ROOT__/{$p.big}" alt="" /></list>
				</div>
			</div>
			<div class="lie">
				<div class="lie_l">
					
				</div>
				<div class="lie_m">
					<ul>
						<list from="$pic" name="p">
							<li><img src="__ROOT__/{$p.big}" alt="" /></li>
						</list>
					</ul>
				</div>
				<div class="lie_r">
					
				</div>
			</div>

		</div>
	<!-- 左边区域结束 -->
	<!-- 右边区域开始 -->
		<div class="fang_r" >
			<style type="text/css">
				.addNum{width:27px;height:30px;text-align:center;line-height:25px;border:1px solid #ccc;display: inline-block;background: #ddd;cursor: pointer;margin-left: 5px;color:#666;font-size: 18px;}
				.addNums{width:27px;height:30px;text-align:center;line-height:27px;border:1px solid #ccc;display: inline-block;background: #ddd;cursor: pointer;margin-right: 5px;color:#666;font-size: 18px;}
			</style>
				<h2 class="p1">{$field.gname}</h2>
				<h2 class="p2">{$field.gname}</h2>
				<p>商品编号：{$field.goods_sn}</p>
				<p>京 东 价：<span class='red_da'>￥ <b style="font-size: 22px;" id="Dprice">{$field.price}</b></span></p>

				<p>商品评分:（<a href="">已有3621人评价</a>）</p>
				<p>配 送 至：
				<select name="" id=""><option value="">北京朝阳区管庄</option></select>
					<strong>有货</strong>，23:00前完成下单，预计<strong>明日（<?php echo date('m月d日',strtotime("+1 day"));?>）</strong>送达
				</p>
				<!-- 属性区域 -->
				<list from="$attrClass" name="ac">
					<p class="chose">
						<span>选择{$ac.attr_name}：</span>
						<list from="$ac._val" name="av">
							<if value="in_array($av['avid'],$stVal)">
								<a avid="{$av.avid}" avalue="{$av.avalue}" href="" class="xuan" onclick="return selectSpec(this);">{$av.avalue}</a>
							<else/>
								<a avid="{$av.avid}" avalue="{$av.avalue}" href="" class="" onclick="return selectSpec(this);">{$av.avalue}</a>
							</if>
						</list>
					</p>
				</list>
				<!-- 属性区域结束 -->
			<form action="{|U('Cart/add')}" method="post" id="buyGoods">
				<p class="chose">
					购买数量： <button class="addNums">-</button> <input class="bugNum" name="buyNum" id="buyNum" type="text" value="1" style="padding:5px;border:1px solid #ddd; width:30px;" />
					<button class="addNum">+</button>
					<input type="hidden" name="stid" value="{$field.stid}">
					<input type="hidden" name="url" value="gid/{$hd.get.gid}<if value="{$hd.get.avid}">/avid/{$hd.get.avid}</if>">
					<input type="hidden" name="avalue" value="22" class="" id="yxzv">
				</p>
				<p>已&ensp;选&ensp;择：<b class="green fm " id="yixuanze">22</b></p>
				<p>服务：{$field.service}</p>
				<p><a href="" class="jia" id='submit'>加入购物车</a></p>
			</form>
			<script type="text/javascript">
			var avalue='';
			$("a[avid][class='xuan']").each(function(){
				avalue += '-'+$(this).attr('avalue');
			})
			//将隐藏表单加上选中属性
			avalue=avalue.slice(1);
			$('input[name="avalue"]').val(avalue);
			$('#yixuanze').text($('#yxzv').val()); //已选择span

			//选择默认规格属性
				function selectSpec(id){
					//点击之后变为选中样式
					// 记录点击之前的样式
					var pre = $(id).siblings('a').parent().find("a[class='xuan']");
					$(id).siblings().removeClass('xuan').end().addClass('xuan');
					var avid=''; //组合avid为 0_0_0 样式
					$("a[avid][class='xuan']").each(function(){
						avid+='_'+$(this).attr('avid');
					})
					avid=avid.slice(1);
					var gid = {$hd.get.gid};
					$.post("{|U('havingst')}",{gid:gid,avid:avid},function(s){
						if(s==1){
							var url = '__METH__/gid/{$hd.get.gid}/avid/'+avid;
							location.href=url;
						}else{
							// var url = '__METH__/gid/{$hd.get.gid}/avid/{$hd.get.avid}';
							// location.href=url;
							a=0;
							$.msg({str:'没有库存！',shade:1,close:function(){
								// $(id).removeClass('xuan');pre.addClass('xuan');
							}});
							return false;
						}
					})
					return false;
				}
				$('#submit').click(function(){
					$('#buyGoods').submit();
					return false;
				})
				$('.addNum').click(function(){
					var max = {$field.stock};
					if(Number($('#buyNum').val())<max) $('#buyNum').val(Number($('#buyNum').val())+1);
					prices();
					return false;
				})
				$('.addNums').click(function(){
					if(Number($('#buyNum').val())>1) $('#buyNum').val(Number($('#buyNum').val())-1);
					prices();
					return false;
				})
				$('#buyNum').keyup(function(){
					if(Number($('#buyNum').val())<1) $('#buyNum').val(1);
					var max = {$field.stock};
					if(Number($('#buyNum').val())>max) $('#buyNum').val(max);
					prices();
				})

				//计算总价
				var Dprice=Number($('#Dprice').text());
				function prices(){
					$('#Dprice').text(Number($('#buyNum').val())*Dprice+'.00');
				}
			</script>
		</div>
	<!-- 右边区域结束-->
	</div>
	<!-- 放大镜区域结束 -->
	<!-- 主体内容区域 -->
	<div id="content">
		<!-- 左侧 -->
		<div class="content_l">
			<div class="erwei">
				<p>“扫一扫”二维码分享给朋友</p>
			</div>
		</div>
		<!-- 左侧结束 -->
		<!-- 右侧 -->
		<div class="content_r">
			<div class="piao">
				<ul>
					<li class="li1 dian"><a href="javascript:;">商品介绍</a></li>
					<li class="li2"><a href="javascript:;">售后服务</a></li>
				</ul>
			</div>
			<div class="jieshao jj">
				<div class="jieshao_top">
					<span>
						商品名称：{$field.gname|mb_substr:0,20,'utf8'}</span><span>商品编号：{$field.goods_sn}</span><a href=''>品牌：{$field.bid}</a><span>上架时间：{$field.addtime|hd_date:'Y-m-d H:i:s'}</span>
				</div>
				<!-- 此处为商品详细内容 -->
				<div class="nei">
					{$field.body}
					<img src="__TPL__/images/rBEGEU-jOb4IAAAAAAD8Mr6Df-UAAAuiwMts2UAAPxK336.jpg" alt="" />
				</div>
				<!-- 此处为商品详细内容结束 -->
			</div>
			<div class="canshu jj">
				{$field.service}
			</div>
			<div class="baozhang">
				
			</div>
			<div class="jingboshi">
				
			</div>
		</div>
		<!-- 右侧结束 -->
	</div>
	<!-- 主体区域结束 -->
	<include file="__TPL__/foot.html">
<!-- 中间主体区域结束 -->
</div>
</body>
</html>

